package com.chebaohui.iqs.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.chebaohui.iqs.service.ChinaUnionServie;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

/**
 * describe:控制访问层-新-银联支付
 * 
 * @author regas_xie
 *
 */
@Api(value = "china/newUnion", description = "银联支付接口", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@RestController
@RequestMapping(value = "china/newUnion")
public class ChinaUnionPayController {

	@Autowired
	private ChinaUnionServie union;

	@ApiOperation(value = "支付发起", httpMethod = "GET", notes = "银联、微信支付发起")
	@RequestMapping(value = "/money", method = { RequestMethod.POST, RequestMethod.GET })
	public void pricePay(HttpServletRequest request, HttpServletResponse response,
			@ApiParam(value = "订单号", required = true) @RequestParam(value = "orderSid", required = false) String orderSid) {

		union.price(request, response, orderSid);
	}

	@ApiOperation(value = "银联支付后台回调", notes = "银联后台通知接收处理并转发到相应其他服务", hidden = true)
	@RequestMapping(value = "/back", method = { RequestMethod.POST, RequestMethod.GET })
	public void callback(HttpServletRequest request, HttpServletResponse response) {

		union.back(request, response);
	}

	@ApiOperation(value = "支付成功转跳页面", notes = "支付成功后点击返回转调的页面", hidden = true)
	@RequestMapping(value = "/front", method = { RequestMethod.POST, RequestMethod.GET })
	public ModelAndView payFront(HttpServletRequest request, HttpServletResponse response) {

		return union.front(request, response);
	}

}
